fix(llmobs): read the text of Bedrock Converse guardContent blocks - #10173
Conversation
A guardContent block scopes a Bedrock guardrail to part of a Converse turn, usually the user question. The LLM Observability walker treated it as an unsupported block and recorded a placeholder, so the llm span kept the surrounding context and lost the question. Read guardContent.text.text like a plain text block. Input-only block, so response and stream extraction are unchanged. Fixes DataDog#10172
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebe192168c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
What does this PR do?
Reads the text of Bedrock Converse
guardContentblocks when building the LLM Observability input forconverseandconverseStreamrequests, instead of recording them as[Unsupported content type: guardContent].Motivation
guardContentis how a Converse caller scopes a Bedrock guardrail to part of a turn, typically the user's question, with retrieved context left unscanned around it. With the current walker the recordedllmspan keeps the context and loses the question, which is the one part of the prompt anyone reading the span needs. The block is input-only, so response and stream extraction are unchanged.Additional Notes
One unit test in
bedrockruntime.util.spec.jscovers a guarded text block between two plain text blocks. A guarded image block still falls through to the placeholder.Fixes #10172